package com.wangy.sct.common.web.configuration;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * ClassName: GlobalBeanConfiguration <br/>
 * Description:  <br/>
 *
 * @author wangyue
 * @version V1.0.0
 * @date 2018/11/16 2:43 PM
 */
@Configuration
public class GlobalWebMvcConfiguration implements WebMvcConfigurer {

	/**
	 * @Description: 全局支持跨域
	 * @param: [registry]
	 * @return: void
	 * @author: wangyue
	 * @Date: 2018/11/20 6:44 PM
	 */
	@Override
	public void addCorsMappings(CorsRegistry registry) {
		System.out.println("<<<<<GlobalWebMvcConfiguration.addCorsMappings>>>>>");
		registry.addMapping("/**")
				.allowedOrigins("*")
				.allowCredentials(true)
				.allowedMethods("GET", "POST", "DELETE", "PUT")
				.maxAge(3600 * 24);
	}
}
